package com.ali.ttt.netty.cluster.controller;

import com.ali.ttt.netty.cluster.config.Cluster;
import com.ali.ttt.netty.cluster.domain.ClientList;
import com.ali.ttt.netty.common.domain.Client;
import com.ali.ttt.netty.common.domain.SessionMap;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author : yuxl
 * @create 2024/7/5 6:10 PM
 */
@Slf4j
@RestController
@RequestMapping("/nettyServer/cluster")
@Api(tags = "Netty服务端:集群")
public class NettyServerClusterController {

    @Resource
    private Cluster cluster;

    @GetMapping("/getAll")
    @ApiOperation(value = "查询全部集群")
    public List<Client> getAll() {
        return cluster.getAll();
    }

    @GetMapping("/getServerList")
    @ApiOperation(value = "查询连接的节点数")
    public ClientList getServerList() {
        return ClientList.inst();
    }

    @GetMapping("/getClientMap")
    @ApiOperation(value = "查询被连接的节点数")
    public SessionMap getClientMap() {
        return SessionMap.inst();
    }
}
